package cn.fjssj.demo02.model.vo;

import cn.fjssj.demo02.converter.SexConverter;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

@Data
@ColumnWidth(10) // 指定的列宽来生成了文件。
public class PandaExportVO implements Serializable {
    @Serial
    @ExcelIgnore
    private static final long serialVersionUID = 1L;

    @ExcelIgnore
    private Long id;

    @ExcelProperty(value = "熊猫昵称", index = 0)
    private String nickname;

    // 这个转换器一眼就能看明白，当EasyExcel发现某个字段装载了特定的转换器时，在写入单元格数据时，
    // 就会触发自定义的convertToExcelData()逻辑，最终将数据转换成自定义的格式~
    @ExcelProperty(value = "性别", index = 1, converter = SexConverter.class)
    private Integer sex;

    @ExcelProperty(value = "唯一编码", index = 2)
    private String uniqueCode;

    @ExcelProperty(value = "身高", index = 3)
    private BigDecimal height;

    @ExcelProperty(value = "出生日期", index = 4)
    @DateTimeFormat("yyyy-MM-dd")
    @ColumnWidth(15)
    private Date birthday;

    @ExcelProperty(value = "创建时间", index = 5)
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    @ColumnWidth(20)
    private Date createTime;
}
